<script type="text/javascript">
    $(function() {
        $("#theTable tr:even").addClass("stripe1");
        $("#theTable tr:odd").addClass("stripe2");

        $("#theTable tr").hover(
        function() {
            $(this).toggleClass("highlight");
        },
        function() {
            $(this).toggleClass("highlight");
        }
    );
    });
    function deleteRow(ID) {
        bersihkanPesan('#messages');
        
        var id	= ID;
        var cari = $("#nomor").val();
        var pilih = confirm('Data yang akan dihapus  = '+id+ '?');
        if (pilih==true) {
            $.ajax({
                type	: "POST",
                url	: "modul/simpanan/hapus.php",
                data	: "id="+id,
                success	: function(data){
                    pesanInfo('#messages', 'Data berhasil dihapus');
                    $("#tampil_data1").load("modul/simpanan/tampil_data1.php?cari="+cari);
                }
            });
        }
    }
    
    function prepareEdit(idJenis, jumlah, tanggal) {
        bersihkanPesan('#messages');
        $('#jenis').val(idJenis);
        $('#jml').val(jumlah);
        $('#tgl').val(tanggal);
        editMode = true;
    }
    
</script>

<?php
// www.contoh-ta.com
//author : asep setiawan & Team
ini_set('display_errors', 1);
ini_set('error_reporting', E_ERROR);

include '../../inc/logging.php';
include '../../inc/inc.koneksi.php';
include '../../inc/fungsi_tanggal.php';

$cari = $_GET['cari'];
$where = " WHERE noinduk='$cari'";

$table = "";
$table .= "<table id='theTable' width='100%'>";
$table .= "<tr>";
$table .= "<th width='5%'>No</th>";
$table .= "<th>Tanggal</th>";
$table .= "<th>SPP</th>";
$table .= "<th>Jumlah</th>";
$table .= "<th>Aksi</th>";
$table .= "</tr>";

$sql = "";
$sql .= " SELECT A.*, B.nama_bulan ";
$sql .= " FROM spp AS A ";
$sql .= " JOIN bulan AS B ON A.id_jenis = B.id_bulan ";
$sql .= $where;
$sql .= " ORDER BY a.id_spp DESC ";

note('SQL: ' . $sql);

$query = mysql_query($sql);
$rows = mysql_num_rows($query);
$no = 1;
while ($result = mysql_fetch_array($query)) {
    note('RESULT: ' . $result);
    
    $table .= "<tr>";
    $table .= "<td align='center'>" . $no. "</td>";
    $table .= "<td align='center'>" . jin_date_str($result['tgl']) . "</td>";
    $table .= "<td>" . $result['nama_bulan'] . "</td>";
    $table .= "<td align='right'>" . number_format($result['jumlah']) . "</td>";
    $table .= "<td align='center'>";
    $table .= "<a href='javascript:deleteRow(\"{$result['id_spp']}\")'>Hapus</a>&nbsp;&nbsp;&nbsp;";
    $table .= "<a href='javascript:prepareEdit(\"" . $result['id_jenis'] . "\",\"" . $result['jumlah'] . "\",\"" . jin_date_str($result['tgl']) . "\")'>Edit</a>";
    $table .= "</td>";
    $table .= "</tr>";
    
    $no++;
}

$table .= "<tr>";
$table .= "<td colspan='4' align='center'>Banyaknya Pembayaran</td>";
$table .= "<td><b>" . number_format($rows) . " Kali</b></td></tr>";
$table .= "</table>";

if ($rows > 0) {
    echo $table;
} else {
    echo "";
}

?>